//
//  InvoiceStatisticsVC.m
//  NtoccShipper
//
//  Created by mac on 2019/12/27.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "InvoiceStatisticsVC.h"
#import "InvoiceStatisticListVC.h"

@interface InvoiceStatisticsVC ()<WMMenuItemDelegate>
@property (nonatomic,strong) NSMutableArray *arrBadgeNums;
@end

@implementation InvoiceStatisticsVC
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.tintColor = [UIColor cjMainTextColor];
    self.navigationController.navigationBar.barTintColor = [UIColor cjWhiteColor];

    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
- (void)viewDidLoad {
    // Do any additional setup after loading the view.
    
   self.arrBadgeNums = [[NSMutableArray alloc]initWithCapacity:7];
   for (int i = 0; i < 7; i++) {
       [self.arrBadgeNums addObject:@"0"];
     }
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 44)];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.font = [UIFont cjTitleFont18];
    titleLabel.textColor = [UIColor cjMainTextColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"发票列表";
    self.navigationItem.titleView = titleLabel;
    
    UIImage *img = [[UIImage imageNamed:@"zcj_arrow_back"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem * leftItem = [[UIBarButtonItem alloc] initWithImage:img style:UIBarButtonItemStyleDone target:self action:@selector(leftBarBtnClicked)];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    self.titleArray = @[@"全部",@"待审核",@"已开票",@"已取消"];//,@"审核通过",@"审核驳回",@"审核中"
    self.titles = @[@"0",@"1",@"2",@"3"];//,@"4",@"5",@"6"
    
     self.menuViewStyle = WMMenuViewStyleLine;
     self.titleSizeSelected = 16;
     self.titleSizeNormal = 14;
     //
     self.progressViewIsNaughty = YES;
     self.progressWidth = 30;
     self.progressHeight = 2;
     self.titleColorNormal = [UIColor cjMainTextColor];
     self.titleColorSelected = [UIColor cjMainColor];
     //   self.preloadPolicy = WMPageControllerPreloadPolicyNever;
     //         self.menuBGColor = [UIColor whiteColor];
     self.showOnNavigationBar = NO;
//    self.delegate = self;
//    self.menuView.delegate = self;
     [super viewDidLoad];
//    CJRegisterNotify(@"AliPay_ChongZhi", @selector(popToMyAcount));

}

- (void)leftBarBtnClicked{
     [self.navigationController popViewControllerAnimated:YES];
}

//- (void)popToMyAcount{
//
////    [CJAlert showStringDismissWithDelay:@"---"];
////    [self updateTitle:@"" atIndex:1];
////[self reloadData];
//
//
//    [self.arrBadgeNums removeAllObjects];
//
//    for (int i = 0; i < 7; i++) {
//
//        if (i%2 == 0) {
//            [self.arrBadgeNums addObject:@"1"];
//
//        }else{
//            [self.arrBadgeNums addObject:@"0"];
//        }
//
//        [self.menuView updateBadgeViewAtIndex:i];
//    }
//}


//1、返回分页数量，可以再这里设置标题栏各种样式
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return 4;
}

//3、把标题与分页对应起来
- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    return _titleArray[index];
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    
    InvoiceStatisticListVC* vc  = [[InvoiceStatisticListVC alloc]init];
    vc.indexPage = self.titles[index];
//    vc.search_condition = self.titles[index];
    vc.strCode = self.strCode;
    return vc;
}

- (CGFloat)menuView:(WMMenuView *)menu widthForItemAtIndex:(NSInteger)index {
    CGFloat width = [super menuView:menu widthForItemAtIndex:index];
    return width ;
}



///**
// *  角标 (例如消息提醒的小红点) 的数据源方法，在 WMPageController 中实现这个方法来为 menuView 提供一个 badgeView
//    需要在返回的时候同时设置角标的 frame 属性，该 frame 为相对于 menuItem 的位置
// *
// *  @param index 角标的序号
// *
// *  @return 返回一个设置好 frame 的角标视图
// */
//- (UIView *)menuView:(WMMenuView *)menu badgeViewAtIndex:(NSInteger)index{
//
//    NSString *indexNum = self.arrBadgeNums[index];
//
//   UIView *view = nil;
//   if(indexNum.intValue != 0)
//   {
//       view = [[UIView alloc] initWithFrame:CGRectMake(self.menuItemWidth-15, 5, 15, 15)];
//       view.layer.cornerRadius = 7.5;
//       view.layer.masksToBounds = YES;
//       view.backgroundColor = [UIColor cjRedColor];
//       UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, view.width, view.height)];
//       lab.textColor = [UIColor cjWhiteColor];
//       lab.text = @"19";
//       lab.textAlignment = NSTextAlignmentCenter;
//       lab.adjustsFontSizeToFitWidth = YES;
//       lab.font = [UIFont boldSystemFontOfSize:10];
////       [lab setFont:[UIFontfontWithName:@"Helvetica-Bold"size:10]];
//       lab.backgroundColor = [UIColor cjClearColor];
//       [view addSubview:lab];
//   }
//    DLog(@"======= %ld",(long)index);
//
//    return view;
//
//}



- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    
    menuView.backgroundColor = [UIColor clearColor];
    //    CGFloat leftMargin = self.showOnNavigationBar ? 0 : 0;
//    CGFloat originY = self.showOnNavigationBar ? 0 : CGRectGetMaxY(self.navigationController.navigationBar.frame);
    return CGRectMake(0, kTopHeight, self.view.frame.size.width, 44);
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
    
    CGFloat originY = CGRectGetMaxY([self pageController:pageController preferredFrameForMenuView:self.menuView]);
    return CGRectMake(0, originY, self.view.frame.size.width, self.view.frame.size.height - originY);
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
